package main

import (
	"awesomeProject/study"
	"fmt"
)

//TIP <p>To run your code, right-click the code and select <b>Run</b>.</p> <p>Alternatively, click
// the <icon src="AllIcons.Actions.Execute"/> icon in the gutter and select the <b>Run</b> menu item from here.</p>

func main() {
	//easyStudy()
	//escapeTest()
	//study.BaseIotaTest()
	//funcTest()
	//study.SliceTest()
	//study.MapTest()\
	//study.TestError()
	//study.ChannelTestBase()
	//study.TestTags()

	testArry := []int{1, 2, 5}
	testSpil := make([]int, 0, 3)
	testSpil = append(testSpil, testArry...)
	testChangeArrays(testArry, testSpil)
	fmt.Println(testArry)
	fmt.Println(testSpil)
	fmt.Printf("原地址：%p", &testArry)
	fmt.Printf("切片地址:%p\n", &testSpil)
}
func testChangeArrays(array []int, spil []int) {
	array[0] = 999
	spil[0] = 999
	fmt.Printf("函数数组地址：%p\n", &array)
	fmt.Printf("切片地址: %p\n", &spil)
}

func funcTest() {
	divide, err := study.Divide(1, 0)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(divide)
	}
}

func escapeTest() {
	//闭包测试
	counter := study.Counter()
	fmt.Println(counter())
	fmt.Println(counter())
}

func easyStudy() {
	//TIP <p>Press <shortcut actionId="ShowIntentionActions"/> when your caret is at the underlined text
	// to see how GoLand suggests fixing the warning.</p><p>Alternatively, if available, click the lightbulb to view possible fixes.</p>
	s := "gopher"
	fmt.Println("Hello and welcome", s)

	for i := 1; i <= 5; i++ {
		//TIP <p>To start your debugging session, right-click your code in the editor and select the Debug option.</p> <p>We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
		// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.</p>
		fmt.Println("i =", 100/i)
	}
	study.Study()
	var funcs []func()
	for i := 0; i < 3; i++ {
		funcs = append(funcs, func() { fmt.Println(i) })
	}
	// 循环结束后，i的值为3

	for _, f := range funcs {
		f() // 输出3 3 3
	}
}
